package com.mumu.muPictureBackend.common;


import com.mumu.muPictureBackend.exception.ErrorCode;

/**
 * 响应工具类
 */
public class ResultUtils {
    /**
     *
     * @param data 数据
     * @param <T>  返回数据的类型
     * @return 返回成功
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(0, data, "ok");
    }

    public static <T> BaseResponse<T> success() {
        return new BaseResponse<>(0, null, "ok");
    }

    public static BaseResponse<?> error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    public static BaseResponse<?> error(ErrorCode errorCode, String message) {
        return new BaseResponse<>(errorCode, message);
    }


    public static BaseResponse<?> error(int code, String massage) {
        return new BaseResponse<>(code, null, massage);
    }

}
